<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">

    <ui:define name="title">API基础项配置列表</ui:define>
    <ui:define name="content">
        <h:form>

            <!--菜单 -->
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton value="批量模式"
                                         icon="fa fa-list-ul"
                                         actionListener="#{templateItemListBean.changeModeToBatch}"
                                         update="@form"
                                         process="@this"
                                         rendered="#{templateItemListBean.isNotBatch()}"/>
                        <p:commandButton value="常规模式" icon="fa fa-file"
                                         actionListener="#{templateItemListBean.changeModeToNormal}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{templateItemListBean.isBatch()}"/>
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"/>
                        <p:columnToggler datasource="itemListDataTable" trigger="toggler"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{templateItemListBean.isNormal()}"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{templateItemListBean.onReset}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{templateItemListBean.isNormal()}"/>
                        <p:commandButton icon="fa fa-plus" value="新增"
                                         action="#{templateItemListBean.onAdd}"
                                         rendered="#{templateItemListBean.isNormal()}">
                            <f:setPropertyActionListener value="/views/templateConf/itemConf/itemlist.xhtml"
                                                         target="#{currentUserBean.back}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <!--菜单 -->

            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">

                        <!-- 搜索框 -->
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="id" value="一级项ID"/>
                                <p:inputText id="id" value="#{templateItemListBean.$.id}"/>

                                <p:outputLabel for="title" value="一级项名"/>
                                <p:inputText id="title" value="#{templateItemListBean.$.title}"/>
                            </p:panelGrid>
                        </div>
                        <!-- 搜索框 -->

                        <!-- 列表 -->
                        <div class="cad">
                            <p:dataTable id="itemListDataTable"
                                         style="width: 100%"
                                         var="item"
                                         value="#{templateItemListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="100%"
                                         reflow="true"
                                         selection="#{templateItemListBean.selectedRecords}"
                                         resizableColumns="true">

                                <p:column headerText="操作" rendered="#{templateItemListBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-eye"
                                                   action="#{templateItemListBean.onEdit(item.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/templateConf/itemConf/itemlist.xhtml"
                                                target="#{currentUserBean.back}"/>
                                        <p:menuitem value="删除" icon="fa fa-remove"
                                                    actionListener="#{templateItemListBean.onDelete(item.id)}"
                                                    process="@this" update="@form">
                                            <p:confirm header="提示信息" message="是否确定删除?" icon="ui-icon-alert"/>
                                        </p:menuitem>
                                        <p:menuitem value="编辑二级项" icon="ui-icon-arrowrefresh-1-w"
                                                    action="#{templateItemListBean.onSecondItem(item.id)}">
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple" style="width:16px;text-align:center"
                                          rendered="#{templateItemListBean.isBatch()}"/>
                                <p:column headerText="项ID" width="5%">
                                    <h:outputText value="#{item.id}"/>
                                </p:column>
                                <p:column headerText="一级项名">
                                    <h:outputText value="#{item.title}"/>
                                </p:column>
                                <p:column headerText="实现方式">
                                    <h:outputText value="#{item.typeName}"/>
                                </p:column>
                                <p:column headerText="所属大项">
                                    <h:outputText value="#{item.projectName}"/>
                                </p:column>
                                <p:column headerText="内部Key名">
                                    <h:outputText value="#{item.dataKey}"/>
                                </p:column>
                                <p:column headerText="创建时间">
                                    <h:outputText value="#{item.createTime}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                        <!-- 列表 -->

                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>